import sys
from os.path import join


def configure(conf):
    pass


def build(bld):
    subdirs = [
        "jpcommon",
        "mecab2njd",
        "njd",
        "njd2jpcommon",
        "njd_set_accent_phrase",
        "njd_set_accent_type",
        "njd_set_digit",
        "njd_set_long_vowel",
        "njd_set_pronunciation",
        "njd_set_unvoiced_vowel",
        "text2mecab",
    ]

    src = []
    for name in subdirs:
        s = bld.path.parent.ant_glob(join("**", name, "*.c"))
        if len(s) > 0:
            src.extend(s)
        h = bld.path.parent.ant_glob(join("**", name, "*.h"))
        if len(h) > 0:
            bld.install_files('${HPREFIX}/' + name, h)

    inc = map(lambda s: join("..", s), subdirs)

    bld.shlib(
        source=src,
        target=bld.env['APPNAME'],
        vnum=bld.env['VERSION'],
        includes=['.'] + inc)
